package ru.ifmo;

import java.util.Vector;

/**
 * Created by Admin on 03.02.15.
 */
public class SmartSpaceTriplet {
    /**
     * triplet with subjectType = "uri"
     * and with objectType = "literal"
     */
    private String subject;
    private String predicate;
    private String object;

    public SmartSpaceTriplet(String subject, String predicate, String object) {
        this.subject = subject;
        this.predicate = predicate;
        this.object = object;
    }

    public SmartSpaceTriplet(Vector<String> triplet) {
        subject = triplet.elementAt(0);
        predicate = triplet.elementAt(1);
        object = triplet.elementAt(2);
    }

    public String getSubject() {
        return subject;
    }

    public String getPredicate() {
        return predicate;
    }

    public String getObject() {
        return object;
    }

    public Vector<String> getTriplet() {
        Vector<String> triplet = new Vector<String>();
        triplet.add(subject);
        triplet.add(predicate);
        triplet.add(object);
        triplet.add("uri");
        triplet.add("literal");
        return triplet;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public void setPredicate(String predicate) {
        this.predicate = predicate;
    }

    public void setObject(String object) {
        this.object = object;
    }

    public void setTriplet(Vector<String> triplet) {
        if (triplet.size() != 3 ) {
            throw new IllegalArgumentException("Triplet must include subject, predicate, object.");
        }

        subject = triplet.elementAt(0);
        predicate = triplet.elementAt(1);
        object = triplet.elementAt(2);
    }

    @Override
    public String toString() {
        return String.format("Subject: %s, predicate: %s, object: %s", subject, predicate, object);
    }
}
